$(function () {
//声明变量
    
    var productStock_datagrid = $("#productStock_datagrid");
    


    productStock_datagrid.datagrid({
        url:'/productStock/query.do',
        fit:true,
        fitColumns:true,
        pagination:true,
        toolbar:'#productStock_toolbar',
        singleSelect:true,
        columns:[[
            {field:'id'},
            {field:'depot',title:'仓库',width:80, formatter:function (value,row,index) {
                    //当前对象是否存在
                    return row? row.d_name:'';
                }},
            {field:'product.sn',title:'商品编码',width:80, formatter:function (value,row,index) {
                    //当前对象是否存在
                    return row? row.p_sn:'';
                }},
            {field:'product.name',title:'商品名称',width:80, formatter:function (value,row,index) {
                    //当前对象是否存在
                    return row? row.p_name:'';
                }},
            {field:'price',title:'库存价格',width:80},
            {field:'storeNumber',title:'库存数量',width:80},
            {field:'amount',title:'总价值',width:80}
        ]]
    });


    $("#depotId").combobox({
        panelHeight:'auto',
        textField:'name',
        valueField:'id',
        url:'/depot/selectAll.do',
        editble:false
    });

    var methodObj = {

        query:function (){
            //获取查询条件
            var keyword =  $("#keyword").textbox('getValue');
            var depotId = $("#depotId").combobox('getValue')
            //通过datagrid 的 load方法传递参数
            productStock_datagrid.datagrid('load',{
                keyword:keyword
                /*hireDate:hireDate*/
            });
            productStock_datagrid.datagrid('load',{//这个是数据表格,下面函数是获取数据表达的值
                depotId:depotId
            });
        },
        //刷新按钮
        refresh:function () {
            //刷新页面
            productStock_datagrid.datagrid('reload');
        }

    };

    //统一绑定事件:
    $("a[data-cmd]").click(function () {
        var methodname = $(this).data("cmd");
        //动态获取调用方法名字,调用方法;
        methodObj[methodname]();
    })

});

//删除

//编辑

//============表单的 按钮 保存/取消=================


//保存密码


//高级查询


//修改密码

